package com.atguigu.study.controller;

import com.atguigu.study.entities.User;
import com.atguigu.study.exp.BusinessException;
import com.atguigu.study.resp.ResultData;
import com.atguigu.study.resp.ReturnCodeEnum;
import com.atguigu.study.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
@RestController
public class UserController
{
    @Resource
    private UserService userService;

    @PostMapping(value = "/user/add")
    public ResultData<Boolean> addUser(@RequestBody User user)
    {
        return ResultData.success(userService.save(user));
    }

    //http://localhost:2404/user/22
    @GetMapping(value = "/user/{id}")
    public ResultData<User> getUserById(@PathVariable("id") Integer id)
    {
        return ResultData.success(userService.getById(id));
    }

}














/*

POST http://localhost:2404/user/add
Accept: application/json
Content-Type: application/json
{
"username": "尚硅谷04",
"password": "13911111112",
"sex": "1"
}

*/
